import DataItemModel from "../../../cfw/mvc/DataItemModel";
import { BottleItemModelEnum } from "../../../public/GameEnumConfig";
import User from "../../db/User";
import { ItemState } from "../../../cfw/tools/Define";
import Player from "../../player/Player";
/**
* 染料瓶
**/
export default class BottleItemModel extends DataItemModel {

	static CLASS_NAME: string = 'BottleItemModel'

	// 消费道具
	getCostItem() {
		return this.data[BottleItemModelEnum.costItem]
	}
	getOpenLevel() {
		return this.data[BottleItemModelEnum.adge]
	}
	isOpen(){
		return Player.instance().getLevel() >= this.data[BottleItemModelEnum.adge]
	}
	needBuy() {
		let list = this.getCostItem();
		return list && list.length > 0 && this.getState() != ItemState.GOT;
	}


	init(id, data) {
		super.init(id, data)
		this.setState(User.instance().getBottleState(this.ID))
	}


	setState(state) {
		super.setState(state)
		User.instance().setBottleState(this.ID, state)
	}



}